package com.job.yangshida;

/**
 * @author yang
 * @version 1.0
 * @since 2022-07-01 23:34:26
 */
public class UseArray0701 {
    public static void main(String[] args) {
        //动态初始化数组 不指定数组
        int[] arr=new int[3];
        //静态初始化 指定数据0     1       2    3     4     5
        String[] names={"Lucy","张三","王五","李四",null,"Jack"};
        //length数据个数也叫数组长度
        System.out.println(names.length);
        //数组通过下标来获取数据,下标index从0开始
        System.out.println(names[0]);
        System.out.println(names[names.length-1]);
        //下标不能越界0--长度-1
        //System.out.println(names[names.length]);
        System.out.println("发红包");
        System.out.println(names[2]);
        names[2]="王六";
        System.out.println(names[2]);
        //遍历是最常见的操作,按照某种顺序逐个访问数据
        for (int i=0;i<names.length;i++){
            System.out.println(i+"\t"+names[i]);
        }
        for (int i=names.length-1;i>=0;i--){
            System.out.println(i+"****"+names[i]);
        }
    }
}
